<template>
	<view class="padding36 ">
		<view class="flex-between mb40">
			<view>押金</view>
			<view>{{$formatNumber(orderData.deposit)}}加元</view>
		</view>
		<view class="flex-between mb40">
			<view>房租</view>
			<view>{{$formatNumber(orderData.rent)}}加元</view>
		</view>
		<van-divider />

		<view class="flex-between mb40">
			<view>合计金额</view>
			<view>{{$formatNumber(orderData.fee)}}加元</view>
		</view>
		<view class="flex-between mb40">
			<view>优惠</view>
			<view class="grey-tips flex-between">
				<span >减</span>
				<input class="my-border-b ml10"  v-model.number="discount" style="width: 100rpx"
					type="number" />
				<span>加元</span>
			</view>
		</view>
		<view class="flex-between mb50 my-m-title">
			<view>合计金额</view>
			<view class="color-red">{{$formatNumber(orderData.fee - discount)}}<span class="f28">加元</span> </view>
		</view>

		<view class="center-all ">
			<view @click="cancel" class="my-disable-btn ">取 消</view>
			<view @click="confirmOrder" class="ml20  my-yellow-btn ">确 定</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				discount: '',
				orderData: this.$getStorage('orderData')
			}
		},
		methods: {
			cancel() {
				uni.navigateBack();
			},
			confirmOrder() {
				// if(!Number(this.discount)) {
				// 	this.$toast('请输入优惠金额');
				// 	return
				// }
				if(this.discount > this.orderData.fee*0.5) {
					this.$toast('优惠金额不能大于房租的百分50');
					return
				}
				let data = {
					order_number: this.orderData.order_number,
					discount: this.discount
				}
				this.$http.confirmOrder(data).then(res => {
				  this.$goPage(3, '/subOrder/orderDetail?orderNumber=' + this.orderData.order_number);
				   uni.$emit('refreshOrderData');
				});
			},
		}
	}
</script>

<style>
</style>